********************************************************************************
** Do file: g1_paper_facts.do
** First started: July 25, 2021 
** Last edited: September 8, 2023

/* Purpose: this do file generates facts used in the paper that do not come from elsewhere within the paper
*/

********************************************************************************

clear
clear matrix
clear mata
set maxvar 10000

* What % of money borrowed by households is secured by a physical asset (house, land, livestock, or vehicle?)

use "$bsvy_clean/10B_loans.dta", clear

* Circle through amounts for all loans, by how it was collateralized
forv x = 1/10 {
	g repay_loan_`x'_crops = .
	replace repay_loan_`x'_crops = repay_loan_`x' if (collateral_loan_`x'==1)
	
	g repay_loan_`x'_house = .
	replace repay_loan_`x'_house = repay_loan_`x' if (collateral_loan_`x'==2)
	
	g repay_loan_`x'_land = .
	replace repay_loan_`x'_land = repay_loan_`x' if (collateral_loan_`x'==3)
	
	g repay_loan_`x'_letter = .
	replace repay_loan_`x'_letter = repay_loan_`x' if (collateral_loan_`x'==4)
	
	g repay_loan_`x'_livestock = .
	replace repay_loan_`x'_livestock = repay_loan_`x' if (collateral_loan_`x'==5)
	
	g repay_loan_`x'_salary = .
	replace repay_loan_`x'_salary = repay_loan_`x' if (collateral_loan_`x'==6)
	
	g repay_loan_`x'_vehicle = .
	replace repay_loan_`x'_vehicle = repay_loan_`x' if (collateral_loan_`x'==7)
	
	g repay_loan_`x'_nocoll = .
	replace repay_loan_`x'_nocoll = repay_loan_`x' if (collateral_loan_`x'==8)
	
	g repay_loan_`x'_guar = .
	replace repay_loan_`x'_guar = repay_loan_`x' if (collateral_loan_`x'==9)
	
	g repay_loan_`x'_atm = .
	replace repay_loan_`x'_atm = repay_loan_`x' if (collateral_loan_`x'==10)
	
	g repay_loan_`x'_asset = .
	replace repay_loan_`x'_asset = repay_loan_`x' if (collateral_loan_`x'==11)
	
	g repay_loan_`x'_bus = .
	replace repay_loan_`x'_bus = repay_loan_`x' if (collateral_loan_`x'==12)
	
	g repay_loan_`x'_savings = .
	replace repay_loan_`x'_savings = repay_loan_`x' if (collateral_loan_`x'==13)
	
	g repay_loan_`x'_labor = .
	replace repay_loan_`x'_labor = repay_loan_`x' if (collateral_loan_`x'==14)
	
	g repay_loan_`x'_natid = .
	replace repay_loan_`x'_natid = repay_loan_`x' if (collateral_loan_`x'==15)
	
	g repay_loan_`x'_shs = .
	replace repay_loan_`x'_shs = repay_loan_`x' if (collateral_loan_`x'==16)
}

* Sum up by category
egen repay_loan_crops = rsum(repay_loan_1_crops repay_loan_2_crops repay_loan_3_crops repay_loan_4_crops repay_loan_5_crops repay_loan_6_crops repay_loan_7_crops repay_loan_8_crops repay_loan_9_crops repay_loan_10_crops)

egen repay_loan_house = rsum(repay_loan_1_house repay_loan_2_house repay_loan_3_house repay_loan_4_house repay_loan_5_house repay_loan_6_house repay_loan_7_house repay_loan_8_house repay_loan_9_house repay_loan_10_house)

egen repay_loan_land = rsum(repay_loan_1_land repay_loan_2_land repay_loan_3_land repay_loan_4_land repay_loan_5_land repay_loan_6_land repay_loan_7_land repay_loan_8_land repay_loan_9_land repay_loan_10_land)

egen repay_loan_letter = rsum(repay_loan_1_letter repay_loan_2_letter repay_loan_3_letter repay_loan_4_letter repay_loan_5_letter repay_loan_6_letter repay_loan_7_letter repay_loan_8_letter repay_loan_9_letter repay_loan_10_letter)

egen repay_loan_livestock = rsum(repay_loan_1_livestock repay_loan_2_livestock repay_loan_3_livestock repay_loan_4_livestock repay_loan_5_livestock repay_loan_6_livestock repay_loan_7_livestock repay_loan_8_livestock repay_loan_9_livestock repay_loan_10_livestock)

egen repay_loan_salary = rsum(repay_loan_1_salary repay_loan_2_salary repay_loan_3_salary repay_loan_4_salary repay_loan_5_salary repay_loan_6_salary repay_loan_7_salary repay_loan_8_salary repay_loan_9_salary repay_loan_10_salary)

egen repay_loan_vehicle = rsum(repay_loan_1_vehicle repay_loan_2_vehicle repay_loan_3_vehicle repay_loan_4_vehicle repay_loan_5_vehicle repay_loan_6_vehicle repay_loan_7_vehicle repay_loan_8_vehicle repay_loan_9_vehicle repay_loan_10_vehicle)

egen repay_loan_nocoll = rsum(repay_loan_1_nocoll repay_loan_2_nocoll repay_loan_3_nocoll repay_loan_4_nocoll repay_loan_5_nocoll repay_loan_6_nocoll repay_loan_7_nocoll repay_loan_8_nocoll repay_loan_9_nocoll repay_loan_10_nocoll)

egen repay_loan_guar = rsum(repay_loan_1_guar repay_loan_2_guar repay_loan_3_guar repay_loan_4_guar repay_loan_5_guar repay_loan_6_guar repay_loan_7_guar repay_loan_8_guar repay_loan_9_guar repay_loan_10_guar)

egen repay_loan_atm = rsum(repay_loan_1_atm repay_loan_2_atm repay_loan_3_atm repay_loan_4_atm repay_loan_5_atm repay_loan_6_atm repay_loan_7_atm repay_loan_8_atm repay_loan_9_atm repay_loan_10_atm)

egen repay_loan_asset = rsum(repay_loan_1_asset repay_loan_2_asset repay_loan_3_asset repay_loan_4_asset repay_loan_5_asset repay_loan_6_asset repay_loan_7_asset repay_loan_8_asset repay_loan_9_asset repay_loan_10_asset)

egen repay_loan_bus = rsum(repay_loan_1_bus repay_loan_2_bus repay_loan_3_bus repay_loan_4_bus repay_loan_5_bus repay_loan_6_bus repay_loan_7_bus repay_loan_8_bus repay_loan_9_bus repay_loan_10_bus)

egen repay_loan_savings = rsum(repay_loan_1_savings repay_loan_2_savings repay_loan_3_savings repay_loan_4_savings repay_loan_5_savings repay_loan_6_savings repay_loan_7_savings repay_loan_8_savings repay_loan_9_savings repay_loan_10_savings)

egen repay_loan_labor = rsum(repay_loan_1_labor repay_loan_2_labor repay_loan_3_labor repay_loan_4_labor repay_loan_5_labor repay_loan_6_labor repay_loan_7_labor repay_loan_8_labor repay_loan_9_labor repay_loan_10_labor)

egen repay_loan_natid = rsum(repay_loan_1_natid repay_loan_2_natid repay_loan_3_natid repay_loan_4_natid repay_loan_5_natid repay_loan_6_natid repay_loan_7_natid repay_loan_8_natid repay_loan_9_natid repay_loan_10_natid)

egen repay_loan_shs = rsum(repay_loan_1_shs repay_loan_2_shs repay_loan_3_shs repay_loan_4_shs repay_loan_5_shs repay_loan_6_shs repay_loan_7_shs repay_loan_8_shs repay_loan_9_shs repay_loan_10_shs)

* Sum up all loan amounts, across categories (including no collateral)
egen repay_loan = rsum(repay_loan_crops repay_loan_house repay_loan_land repay_loan_letter repay_loan_livestock repay_loan_salary repay_loan_vehicle repay_loan_nocoll repay_loan_guar repay_loan_atm repay_loan_asset repay_loan_bus repay_loan_savings repay_loan_labor repay_loan_natid repay_loan_shs)

* Develop the numerator
egen repay_loan_compare_num = rsum(repay_loan_house repay_loan_land repay_loan_livestock repay_loan_vehicle) // 

* Merge in information for specific households
merge 1:m hhid using "$merged/key_rep.dta", keepusing(k_complete_may k_rolling_list k_interacted_success k_surveyed treatmenttype_sh)

g tag = 1 if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_surveyed==1

* Develop fraction
g repay_loan_frac = repay_loan_compare_num/repay_loan

* Look at fraction
sum repay_loan_frac if tag==1 // ~28%


***************

* Ever refused a loan in last 12 months?

tab ever_refused if tag==1 // 15%



***************

* % of customers who received an SMS about the loan indicating interest
use "$merged/key_rep.dta", clear
tab k_rolling_list if k_complete_may==1

* of the customers who were offered a loan after expressing interest, what % accepted the offer and recieved a loan
* note: this focuses on Secured, Surprise Unsecured, and Unsecured
tab k_tookloan_repay if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U")

* take up rate for customers offered a Secured loan and those offered Unsecured loan
* note: Surprise Unsecured will be counted with Secured, as both were Secured when offers made
* Surprise Unsecured and Secured
tab k_tookloan_repay if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U")
* Unsecured
tab k_tookloan_repay if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & treatmenttype_sh=="R T2-U"

* what % of customers did call center reach?
tab k_interacted_success if k_complete_may==1 & k_rolling_list==1

***************

** Education (Fenix) **

* what % of sample HH had school age children (aged 5-20)
* note: this focuses on Secured, Surprise Unsecured, and Unsecured
merge m:1 hhid using "$bsvy_clean/hhvars_baseline.dta"
keep if _merge==3 | _merge==1
drop _merge
g d_num_520 = (num_520 > 0) if num_520!=.
tab d_num_520 if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_surveyed==1 & (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") // 89% have sac, baseline

	* at endline?
	* What % of sample HH have school aged children?
	* Load key data first
	preserve
	use "$esvy_clean/2_educ_indiv.dta", clear
	g num_sac = 1
	collapse (sum) num_sac, by(hhid)
	tempfile sac
	save `sac'

	* Load key data first
	use "$merged/key_rep.dta", clear
	keep if hhid!=.

	* Restrict down to sample of interest
	keep if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_surveyed==1 & k_surveyed_end==1

	* Merge sac
	merge 1:1 hhid using `sac', keepusing(num_sac)
	keep if _merge==1 | _merge==3
	tab _merge // 89% have sac
	restore

* % of sample HH who accepted a school fee loan using it for school related expenses?
* note: this is conditional on having school aged children (aged 5-20)
merge m:1 hhid using "$esvy_clean/6A_rdypyloanuse.dta", keepusing(readypay_schfee)
keep if _merge==1 | _merge==3
drop _merge
g d_readypay_schfee = (readypay_schfee>0) if readypay_schfee!=.
replace d_readypay_schfee = 0 if d_readypay_schfee==.
tab d_readypay_schfee if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_tookloan_repay==1 & k_surveyed==1 & k_surveyed_end==1 & (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & d_num_520==1 // 92%


* Median number of school aged children
	* For later use: Develop a num_520 variable but for endline
	use "$esvy_clean/2_educ_indiv.dta", clear
	g num_520e = 1
	collapse (sum) num_520e, by(hhid)
	tempfile num_520e_info
	save `num_520e_info'

	* Load key data
	use "$merged/key_rep.dta", clear
	keep if hhid!=.

	* Restrict down to sample of interest
	keep if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_surveyed==1 & k_surveyed_end==1

	* Drop the choice group as well
	drop if treatmenttype_sh=="R T3"

	* Merge in num_520e
	merge 1:1 hhid using `num_520e_info', keepusing(num_520e)
	keep if _merge==3 | _merge==1
	drop _merge
	
	* Replace missing with zero
	replace num_520e = 0 if num_520e == .
	sum num_520e, det // median 3
	sum num_520e if num_520e!=0, det // median 3


* Conditioning on enrollment, what is the effect on attendance?
* Load key data first
use "$merged/key_rep.dta", clear
keep if hhid!=.

* Restrict down to sample of interest
keep if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_surveyed==1 & k_surveyed_end==1

* Endline		
merge 1:1 hhid using "$esvy_clean/2_educ_hh.dta"
keep if _merge==3 | _merge==1
drop _merge

* Drop the choice group as well
drop if treatmenttype_sh=="R T3"

* Develop indicators
g anytreat_actual = (k_tookloan_repay==1)
g locked_actual = (k_tookloan_repay==1 & treatmenttype_sh=="R T1-L")
g surprise_actual = (k_tookloan_repay==1 & treatmenttype_sh=="R T1-U")
g unlocked_actual = (k_tookloan_repay==1 & treatmenttype_sh=="R T2-U")

g anytreat_assigned = (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") 
g locked_assigned = (treatmenttype_sh=="R T1-L")
g surprise_assigned = (treatmenttype_sh=="R T1-U")
g unlocked_assigned = (treatmenttype_sh=="R T2-U")

* Attendance
ivreg2 missed_month_t2_fin (locked_actual surprise_actual unlocked_actual = locked_assigned surprise_assigned unlocked_assigned) // no effects

	
** Education (LSMS) **
* enrollment rates, primary and secondary school school aged children
use "$lsms2018/lsms_vars_indiv.dta", clear

sum enrolled if prim_SAC==1 [aw=wgt*hhsize] // 91%
sum enrolled if sec_SAC==1 [aw=wgt*hhsize] // 68%

* median HH spends how much of income on primary education and on secondary education?
use "$lsms2018/lsms_vars_hh.dta", clear
sum prim_se_inc [aw=wgt], det
sum sec_se_inc [aw=wgt], det 

***************

** Credit **

* what kind of loans do households have?
sum credit_comm [aw=wgt]
sum credit_othformal [aw=wgt]
	sum credit_othformal2 [aw=wgt] // no mobile money involved
sum credit_mfis [aw=wgt]

***************

* What % of HH in the Surprise Unlocked treatment complete the loan within 120 days?
use "$repay_clean/fenix_repay_extend_07172020_rep.dta", clear
merge m:1 accountid using "$merged/key_rep.dta", keepusing(k_complete_may k_rolling_list k_interacted_success k_tookloan_repay)
keep if _merge==3
drop _merge
g tag = 1 if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_tookloan_repay==1
sum completeloan if treatmenttype_sh=="R T1-U" & loandayselapsed==120 & tag==1


***************

** Table 3 things **
* Load repayment dataset
use "$repay_clean/fenix_repay_extend_07172020_rep.dta", clear

* Generate and label compliance variables
g locked_share_wupg_AS = .
replace locked_share_wupg_AS = complier_share_wupg if treatmenttype_sh=="R T1-U"
replace locked_share_wupg_AS = locked_share_wupg if treatmenttype_sh=="R T2-U"
la var locked_share_wupg_AS "Share of days in compliance for Adverse Selection comparison"

* Merge in filter variables
merge m:1 accountid using "$merged/key_rep.dta", keepusing(k_complete_may k_rolling_list k_interacted_success k_tookloan_repay accountpercentlocked_may)
keep if _merge==1 | _merge==3
drop _merge

* Generate tag to subset to customer of interest
g tag = 1 if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_tookloan_repay==1

	* Find the median of risk variable
	preserve
		duplicates drop accountid, force
		tab accountpercentlocked_may if tag==1 & (treatmenttype_sh=="R T1-L" | ///
												treatmenttype_sh=="R T1-U" | ///
												treatmenttype_sh=="R T2-U")
		sum accountpercentlocked_may if tag==1 & (treatmenttype_sh=="R T1-L" | ///
												treatmenttype_sh=="R T1-U" | ///
												treatmenttype_sh=="R T2-U"), det
	restore
	
	* Add risk groups
	g riskabove = (accountpercentlocked_may >= 11)
	
tempfile all
save `all'

* Generate miniature versions of dataset
	preserve
		keep if tag==1
		keep if loandayselapsed == 150
		tempfile data150_strict
		save `data150_strict'
	restore
	preserve
		keep if tag==1
		keep if loandayselapsed == 200
		tempfile data200_strict
		save `data200_strict'
	restore
	


* IV

* 150 - Adverse Selection
use `data150_strict', clear
keep if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") 
g treatment = (treatmenttype_sh=="R T2-U")
replace locked_share_wupg=locked_share_wupg_AS
* Generate interactions
g treat_riskabove = treatment * riskabove
g lockshar_riskabove = locked_share_wupg * riskabove
keep frac_lpp_maxip completeloan riskabove locked_share_wupg lockshar_riskabove treatment treat_riskabove
g asgroup = 1
tempfile asdata_repay1
save `asdata_repay1'

use `data200_strict', clear
keep if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") 
g treatment = (treatmenttype_sh=="R T2-U")
replace locked_share_wupg=locked_share_wupg_AS
* Generate interactions
g treat_riskabove = treatment * riskabove
g lockshar_riskabove = locked_share_wupg * riskabove
keep frac_lpp_maxip completeloan riskabove locked_share_wupg lockshar_riskabove treatment treat_riskabove
g asgroup = 1
tempfile asdata_complete1
save `asdata_complete1'


* 150 - Moral Hazard
use `data150_strict', clear
keep if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U")
g treatment = (treatmenttype_sh=="R T1-L")
* Generate interactions
g treat_riskabove = treatment * riskabove
g lockshar_riskabove = locked_share_wupg * riskabove
keep frac_lpp_maxip completeloan riskabove locked_share_wupg lockshar_riskabove treatment treat_riskabove
g asgroup = 0
tempfile asdata_repay2
save `asdata_repay2'

use `data200_strict', clear
keep if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U")
g treatment = (treatmenttype_sh=="R T1-L")
* Generate interactions
g treat_riskabove = treatment * riskabove
g lockshar_riskabove = locked_share_wupg * riskabove
keep frac_lpp_maxip completeloan riskabove locked_share_wupg lockshar_riskabove treatment treat_riskabove
g asgroup = 0
tempfile asdata_complete2
save `asdata_complete2'

* Repayment investigation
use `asdata_repay1', clear
append using `asdata_repay2'

g cons = 1
ivregress 2sls frac_lpp_maxip c.riskabove#i.asgroup c.cons#i.asgroup (c.locked_share_wupg#i.asgroup c.lockshar_riskabove#i.asgroup = i.treatment#i.asgroup treat_riskabove#i.asgroup), nocons 

test 1.asgroup#c.locked_share_wupg = 0.asgroup#c.locked_share_wupg
test 1.asgroup#c.locked_share_wupg + 1.asgroup#c.lockshar_riskabove = 0.asgroup#c.locked_share_wupg + 0.asgroup#c.lockshar_riskabove // 0.02

* Completion investigation
use `asdata_complete1', clear
append using `asdata_complete2'

g cons = 1
ivregress 2sls completeloan c.riskabove#i.asgroup c.cons#i.asgroup (c.locked_share_wupg#i.asgroup c.lockshar_riskabove#i.asgroup = i.treatment#i.asgroup treat_riskabove#i.asgroup), nocons 

test 1.asgroup#c.locked_share_wupg = 0.asgroup#c.locked_share_wupg
test 1.asgroup#c.locked_share_wupg + 1.asgroup#c.lockshar_riskabove = 0.asgroup#c.locked_share_wupg + 0.asgroup#c.lockshar_riskabove

************


* What about subsamples? Low risk, High risk

* Repayment investigation
use `asdata_repay1', clear
append using `asdata_repay2'

g cons = 1
ivregress 2sls frac_lpp_maxip c.cons#i.asgroup (c.locked_share_wupg#i.asgroup = i.treatment#i.asgroup) if riskabove==0, nocons 
test 1.asgroup#c.locked_share_wupg = 0.asgroup#c.locked_share_wupg
ivregress 2sls frac_lpp_maxip c.cons#i.asgroup (c.locked_share_wupg#i.asgroup = i.treatment#i.asgroup) if riskabove==1, nocons 
test 1.asgroup#c.locked_share_wupg = 0.asgroup#c.locked_share_wupg

* Completion investigation
use `asdata_complete1', clear
append using `asdata_complete2'

g cons = 1
ivregress 2sls completeloan c.cons#i.asgroup (c.locked_share_wupg#i.asgroup = i.treatment#i.asgroup) if riskabove==0, nocons 
test 1.asgroup#c.locked_share_wupg = 0.asgroup#c.locked_share_wupg
ivregress 2sls completeloan c.cons#i.asgroup (c.locked_share_wupg#i.asgroup = i.treatment#i.asgroup) if riskabove==1, nocons 
test 1.asgroup#c.locked_share_wupg = 0.asgroup#c.locked_share_wupg



************


* Take up rate in the control group
use "$merged/key_rep.dta", clear
g tag = 1 if k_complete_may==1 & k_rolling_list==1 
g takeup = (k_tookloan_repay==1)
tab takeup if treatmenttype_sh=="R C" & tag==1 // 8%
tab takeup if treatmenttype_sh=="R C" & tag==1 & k_surveyed==1 & k_surveyed_end==1 // 9% (adding being surveyed as additional criteria)


************

* What percent of the sum between amount paid towards principal and commissions are commissions?
use "$repay_clean/commissions.dta", clear
sum m_cum_diff_diff m_loanpaid_principal

display 170.1348/164040.3

************

* What percent of households in the Surprise Unsecured treatment complete the loan 
* Load repayment dataset
use "$repay_clean/fenix_repay_extend_07172020_rep.dta", clear

* Merge in filter variables
merge m:1 accountid using "$merged/key_rep.dta", keepusing(k_complete_may k_rolling_list k_interacted_success k_tookloan_repay accountpercentlocked_may)
keep if _merge==1 | _merge==3
drop _merge

* Generate tag to subset to customer of interest
g tag = 1 if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_tookloan_repay==1

* Examine figure 
tab completeloan if tag==1 & treatmenttype_sh=="R T1-U" & loandayselapsed==120 // ~ 40%

************

* Shocks, binary variable version *
* Load key data first
use "$merged/key_rep.dta", clear
keep if hhid!=.

* Restrict down to sample of interest
keep if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_surveyed==1 & k_surveyed_end==1

* Merge in shocks information
merge 1:1 hhid using "$esvy_clean/7_wellbeing_hh"
keep if _merge==3 | _merge==1
drop _merge		
			
* Drop the choice group as well
drop if treatmenttype_sh=="R T3"

* Develop indicators
g anytreat_actual = (k_tookloan_repay==1)
g locked_actual = (k_tookloan_repay==1 & treatmenttype_sh=="R T1-L")
g surprise_actual = (k_tookloan_repay==1 & treatmenttype_sh=="R T1-U")
g unlocked_actual = (k_tookloan_repay==1 & treatmenttype_sh=="R T2-U")

g anytreat_assigned = (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") 
g locked_assigned = (treatmenttype_sh=="R T1-L")
g surprise_assigned = (treatmenttype_sh=="R T1-U")
g unlocked_assigned = (treatmenttype_sh=="R T2-U")

* Convert scales to threshold
g scaleAindex2 = (scaleAindex>.67) if scaleAindex!=.
g scaleBindex2 = (scaleBindex>.67) if scaleBindex!=.

* Run regressions
reg scaleAindex2 anytreat_assigned
reg scaleAindex2 locked_assigned surprise_assigned unlocked_assigned

reg scaleBindex2 anytreat_assigned
reg scaleBindex2 locked_assigned surprise_assigned unlocked_assigned
